package com.shrct.businessprocess.budget.impl;

import com.shrct.businessprocess.budget.RCC6Budget;
import com.shrct.businessprocess.budget.RCCostBreakDown;
import com.shrct.businessprocess.budget.impl.RCHasCostBudgetImpl;
import com.shrct.businessprocess.budget.proxy.RCC6BudgetProxy;
import com.shrct.businessprocess.project.RCExchangeRate;
import com.shrct.businessprocess.project.RCProjectMoney;
import edu.fudan.mylang.pf.IObjectFactory;
import javax.persistence.AssociationOverride;
import javax.persistence.AssociationOverrides;
import javax.persistence.AttributeOverride;
import javax.persistence.AttributeOverrides;
import javax.persistence.Column;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import org.eclipse.xtext.xbase.lib.ObjectExtensions;
import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;

@Entity
@DiscriminatorValue("RCC6BUDGET_TYPE")
public class RCC6BudgetImpl extends RCHasCostBudgetImpl implements RCC6Budget {
  public RCC6BudgetImpl() {
    super();
  }
  
  public RCC6BudgetImpl(final RCCostBreakDown cbd) {
    super( cbd);
    
  }
  
  private String name;
  
  public String getName() {
    return this.name;
  }
  
  public RCC6Budget setName(final String name) {
    this.name = name;
    return this;			
    
  }
  
  @Embedded
  @AttributeOverrides(value = { @AttributeOverride(name = "amount", column = @Column(name = "netPrice_amount") ), @AttributeOverride(name = "workaround", column = @Column(name = "netPrice_workaround") ) } )
  @AssociationOverrides(value = @AssociationOverride(name = "exchange", joinColumns = @JoinColumn(name = "netPrice_exchange") ) )
  private RCProjectMoney netPrice = com.shrct.businessprocess.project.RCProjectMoney.create();
  
  public RCProjectMoney getNetPrice() {
    return this.netPrice;
  }
  
  public RCC6Budget setNetPrice(final RCProjectMoney netPrice) {
    this.netPrice = netPrice;
    return this;			
    
  }
  
  public RCProjectMoney getContractPrice() {
    RCProjectMoney _rCProjectMoney = new RCProjectMoney();
    final Procedure1<RCProjectMoney> _function = new Procedure1<RCProjectMoney>() {
        public void apply(final RCProjectMoney it) {
          it.setAmount(Double.valueOf(0d));
          RCCostBreakDown _cbd = RCC6BudgetImpl.this.getCbd();
          RCExchangeRate _exchangeRate = _cbd.getExchangeRate();
          it.setExchange(_exchangeRate);
        }
      };
    RCProjectMoney _doubleArrow = ObjectExtensions.<RCProjectMoney>operator_doubleArrow(_rCProjectMoney, _function);
    return _doubleArrow;
  }
  
  public Double getContractTaxRate() {
    return Double.valueOf(0d);
  }
  
  public Double getNetTaxRate() {
    return Double.valueOf(0d);
  }
  
  public String getTypeId() {
    return "RCC6Budget";
  }
  
  public String getEntityName() {
    return this.name;
  }
  
  public static RCC6Budget create(final RCCostBreakDown cbd, final IObjectFactory objectFactory) {
    com.shrct.businessprocess.budget.RCC6Budget rCC6Budget = new com.shrct.businessprocess.budget.impl.RCC6BudgetImpl(
    	cbd
    );
    objectFactory.create(rCC6Budget);
    return rCC6Budget;			
    
  }
  
  public static RCC6Budget createRCC6BudgetImpl(final RCCostBreakDown cbd, final IObjectFactory objectFactory, final Procedure1<RCC6Budget> init) {
    com.shrct.businessprocess.budget.RCC6Budget rCC6Budget = new com.shrct.businessprocess.budget.impl.RCC6BudgetImpl(
    	cbd
    );
    objectFactory.create(rCC6Budget);
    init.apply(rCC6Budget);
    
    return rCC6Budget;			
    
  }
  
  public RCC6BudgetProxy toProxy() {
    com.shrct.businessprocess.budget.proxy.RCC6BudgetProxy proxy = new com.shrct.businessprocess.budget.proxy.RCC6BudgetProxy();
    proxy.setId(this.getId());
    if(this instanceof edu.fudan.mylang.pf.INamedModelObject){
    	proxy.setName(((edu.fudan.mylang.pf.INamedModelObject)this).getEntityName());
    }
    return proxy;
    
  }
}
